package com.distributed.common.message;

import com.distributed.common.Constant;

import net.sf.json.JSONObject;

public class CancelMessage extends BaseMessage {
	
	public CancelMessage() {
		super();
		setId(Constant.CANCEL_MESSAGE);
	}

	public static String getName() {
		return Constant.CANCEL_MESSAGE_NAME;
	}

	public static CancelMessage getFromString(String message) {
		JSONObject jsonobject = JSONObject.fromObject(message);
		if (jsonobject == null) {
			return null;
		}
		return getFromJSON(jsonobject);
	}

	public static CancelMessage getFromJSON(JSONObject jsonobj) {
		BaseMessage baseMessage = new CancelMessage();
		BaseMessage baseMsg = BaseMessage.getFromJSON(jsonobj, baseMessage);
		if (baseMsg == null || baseMsg.getId() != Constant.CANCEL_MESSAGE) {
			return null;
		}
		
		return (CancelMessage) baseMsg;
	}

	public JSONObject toJSON() {
		return super.toJSON();
	}
	
	public String toString() {
		return toJSON().toString();
	}
}
